'use strict';

var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var cssmin = require('gulp-cssmin');
var concat = require('gulp-concat');

gulp.task('compile-global', function() {
  return gulp.src(['./src/styles/index.scss'])
    .pipe(sass.sync())
    .pipe(autoprefixer({
      browsers: ['ie > 9', 'last 2 versions'],
      cascade: false
    }))
    .pipe(cssmin())
    .pipe(gulp.dest('./src/styles/'));
});
gulp.task('compile-components', function() {
  return gulp.src(['./src/components/styles/*.scss'])
    .pipe(sass.sync())
    .pipe(autoprefixer({
      browsers: ['ie > 9', 'last 2 versions'],
      cascade: false
    }))
    .pipe(cssmin())
    .pipe(gulp.dest('./lib/styles/components'));
});

gulp.task('merge', function() {
  return gulp.src(['./src/styles/reset.css','./src/styles/element-theme/index.css','./src/styles/index.css'])
    .pipe(cssmin())
    .pipe(concat('index.css'))
    .pipe(gulp.dest('./lib/styles/'));
});

gulp.task('copyfont', function() {
  return gulp.src('./src/styles/element-theme/fonts/**')
    .pipe(cssmin())
    .pipe(gulp.dest('./lib/styles/fonts'));
});

gulp.task('build', ['compile-global','compile-components','merge', 'copyfont']);